
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="description" content="">
        <meta name="author" content="">

        <title>后台</title>

        <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

        <!-- Bootstrap core CSS -->
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-switch.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/select2/select2.css" />
        <link href="__PUBLIC__/css/select2/select2-bootstrap.min.css" rel="stylesheet" />
    </head>

    <body>

    <include file="Common/topNav" />

    <div class="container-fluid">
        <div class="row">
            <include file="Common/leftMenu" />
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="cont-title clearfix">
                    <div class="title">内容列表</div>
                    <div class="btn-group"><button type="button" id="addNews"  class="btn">添加</button></div>
                </div>
                <form class="jc-search form-inline searchForm" action="{:U('Admin/News/index')}" method="post">
                    <div class="form-group">
                        <label>新闻标题:</label>
                        <input type="text" class="form-control" name="title" value="{$title}" placeholder="输入新闻标题">
                    </div>
                   
                  
                    <div class="form-group">
                        <label>用户组:</label>
                        <select name="cate_id" id="cateListSelect" style="width: 200px;" >
                            <option value="0">所有分类</option>
                            <volist name="cateList" id="cate">
                                <option <if condition="$cate_id eq $cate['id']">selected="selected"</if> value="{$cate.id}" parent="{$cate.pid}">{$cate.cate_name}</option>
                            </volist>
                        </select>
                    </div>
                    
                    <input class="btn" type="submit" value="搜索" />
                </form>
                <div class="table-responsive">
                    <table class="table table-striped table-hover" id="tableData">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>标题</th>
                                <th>分类</th>
                                <th>作者</th>
                                <th>点击率</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <volist name="newsList['data']" id="news">
                            <tr>
                                <td>{$i}</td>
                                <td>{$news.title}</td>
                                <td>{$news.cate_id|getCateName}</td>
                                <td>{$news.user_id|getUserName}</td>
                                <td>{$news.click}</td>
                                <td>{$news.create_time|date='Y-m-d H:i:s',###}</td>
                                <td>
                                    <a href="javascript:void(0)" newsId="{$news.id}" class="editNews">修改</a> | 
                            
                                <a href="javascript:void(0)" newsId="{$news.id}" class="delNews">删除</a>
                           
                            </td>
                            </tr>
                        </volist>    
                        </tbody>
                    </table>
                    <div class="page">
                    	{$newsList.page}
                    </div>
                </div>
            </div>
        </div>
    </div>
    <include file="Common/modalHtmls" />
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap-switch.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/validator.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/select2/select2.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/select2tree.js"></script>
    <script>
        var Ue = null;
        $(function(){
            $("#cateListSelect").select2tree();
        })
        $("#tableData .editNews").click(function () {
            var newsId = $(this).attr("newsId");
            common.htmlAjax("{:U('Admin/News/editNews')}", {newsId: newsId}, function (html) {
                $("#commonModal").html(html).modal('toggle');
            })
        })

        $("#addNews").click(function () {
            common.htmlAjax("{:U('Admin/News/addNews')}", {}, function (html) {
                $("#commonModal").html(html).modal('toggle');
            })
        })

        $("#tableData .delNews").click(function () {
            var newsId = $(this).attr("newsId");
            common.confirm("提示", "确定删除新闻?", function () {
                common.ajax("{:U('Admin/News/delNews')}", {newsId: newsId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "新闻删除成功!", function () {
                        common.reload();
                    });
                });
            });
        });

        $("#tableData .enUser").click(function () {
            var userId = $(this).attr("userId");
            common.confirm("提示", "确定启用用户?", function () {
                common.ajax("{:U('Admin/User/enUser')}", {userId: userId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "用户启用成功!", function () {
                        common.reload();
                    });
                });
            });
        });
    </script>
</body>
</html>
